class Error(Exception):

    def __init__(self, line, col, name):
        self.line = line
        self.col = col
        self.name = name
        self.msg = '%s: (%s, %s)'

    def __str__(self):
        return self.msg % self.__dict__

    __repr__ = __str__

class SyntaxError(Error):

    def __init__(self, line, col, name):
        Error.__init__(self, line, col, name)
        self.msg = 'Line %(line)s, Col %(col)s'

class DuplicationError(Error):

    def __init__(self, line, col, name):
        Error.__init__(self, line, col, name)
        self.msg = '%(name)r Line %(line)s, Col %(col)s'

class NameError(Error):

    def __init__(self, line, col, name):
        Error.__init__(self, line, col, name)
        self.msg = '%(name)r Line %(line)s, Col %(col)s'

class TypeError(Error):

    def __init__(self, line, col, name, types):
        Error.__init__(self, line, col, name)
        self.x, self.y, self.op = types
        self.msg = '%(x)s %(op)r %(y)s Line %(line)s, Col %(col)s '
